<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">

    <link rel="stylesheet" href="./editor/themes/default/default.css">
    <script charset="utf-8" src="./editor/kindeditor-all-min.js"></script>
    <script charset="utf-8" src="./editor/lang/zh-CN.js"></script>
    
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>    
    <!-- bootstrap.bundle.min.js 用于弹窗、提示、下拉菜单，包含了 popper.min.js -->
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>    
    <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <style>
        .navbar{
            width: 100%;
            height: 80px;
        }
        .nav-pills{
            float: left;
            width: 60%;
            height: 66px;
            line-height: 51px;
            margin: 0 auto;
        }
        .nav-pills>li{
            text-align: center;
            list-style: none;
            /* width: 4rem; */
            float: left;
        }
        .nav-link{
            display: inline-block;
            /* width: 4rem; */
            color: rgb(255, 255, 255);
            font-weight: bold;
        }
        .actives{
            background-color: #56b9f31c;
        }
        .nav-pills .nav-link.active, .nav-pills .show>.nav-link{
            color: rgb(221, 220, 220);
            background-color: #2badf8;
        }
        .imgbox{
            width: 68%;
            height: 66px;
            float: left;
        }
        .key{
            width: 16px;
            font-size: 16px;
            margin-left: 10px;
        }
        .login>a{
            color: rgb(255, 255, 255);
            text-decoration: none;
        }
        .tou{
            width: 63px;
            height: 63px;
            margin-top: 1px;
            border-radius: 50%;
            border: 1px rgb(147, 144, 144) solid;
            float: left;
        }
        .img{
            width: 180px;
            height: 66px;
            float: left;
            padding-right: 20px;
            margin-left: 120px;
        }
        .cotent{
            width: 1400px;
            height: 100vh;
            margin: 0 auto;
            display: flex;
            justify-content: center;
        }
        .contents{
            display: inline-block;
            border: 1px solid #59f7ff;
        }
        .left{
            width: 800px;
            height: 700px;
            background: white;
        }
        .right{
            width: 350px;
            height: 700px;
            margin-left: 45px;
            align-items: flex-start;
        }
        .box{
            background: rgba(0, 0, 0,0.1) url(./imge/bacgroud.jpg) no-repeat;
            background-size: 100% 100%;
            opacity: 0.8;
        }
        .serch{
            margin-top: 1px;
            height: 60px;
            width: 100%;
            display: flex;
            align-items: center;
            background: rgba(239, 244, 255, 1);
        }
        .serchbox{
            display: inline-block;
        }
        .serch_left{
            width: 74%;
            display: flex;
            justify-content: center;
            align-items: center;
            
        }
        .serch_right{
            width: 26%;
            margin-left: -1.5%;

        }

        .articl{
            color: #2badf8;
            line-height: 60px;
            padding: 2px 20px;
        }
        .form-inline{
            display: inline-block;
        }
        .mb-2{
            background: rgba(172, 220, 248, 0.2);
            color: rgb(255, 255, 255);
            border-radius: 5px;
            border: 1px #7a99d7 solid;
        }
        input::-webkit-input-placeholder{
            color: #829fdc;
        }
        .btn-primary{
            margin-top: 1px;
            height: 28px;
            line-height: 1px;
            color: #829fdc;
        }
       .footer{
        width: 100%;
        height: 150px;
        background-color: #e3e3e3;
        text-align: center;
        padding: 0.9rem 0;
        font-size: 0.7rem;
       }
       .footer>p{
        opacity: 0.6;
       }
       .title{
            width: 100%;
       }
       .input-group-prepend{
            width: 10%;
       }
       .form-control{
            text-align: center;
       }
       a{
            text-decoration: none;
            color: rgba(55, 55, 240, 0.812);
        }
        a:hover{
            color: #ff6136;
            text-decoration: none;
        }
        .dropdown-toggle{
            margin-left: 1rem;
            width: 10rem;
            height: 30px;
            line-height: 16px;
            background-color: rgb(180, 217, 227);
            color: rgb(81, 80, 80);
            font-weight: 600;
       }
       .dropdown-item{
            height: 2rem;
            font-size: 0.8rem;
            line-height: 1.5rem;
            /* border-bottom: 1px rgb(176, 174, 174) solid; */
       }
       .cheek_ul{
            padding: 0;
       }
       .cheek_span{
            display: inline-block;
            width: 100%;
            height: 2.5rem;
            line-height: 2.5rem;
            font-size: 1rem;
            padding-left: 3rem;
            border-radius: 5px;
            margin-bottom: 15px;
            font-weight: 600;
            color: aliceblue;
            background-color: #07bcc6;
       }
       .cheek_ul>li{
            display: inline-block;
            list-style: none;
            width: 100%;
            height: 2.53rem;
            border-bottom: 1px rgba(186, 174, 174, 0.425) dashed;
            line-height: 2.5rem;
            font-size: 1rem;
            font-weight: 600;
            color: rgba(55, 55, 248, 0.792);
            padding-left: 3rem;
       }
       .image{
            width: 1.3rem;
            margin-top: -5px;
       }
       .img_right{
           margin-left: 3rem;
       }
       #imgheader{
           width: 90%;
           height: 350px;
           margin-top: 20px;
           box-shadow: #59f7ffb3 0px 1px 10px 0px;
           border-radius: 10px;
           border-bottom: 1px dashed rgb(145, 240, 247);
           background-color: #ecffff41; 
            padding-top: 1rem;
       }
       .imgheader_ul{
            width: 31%;
            height: 60%;
            padding: 0;
            margin-left: 1.35rem;
            list-style: none;
            float: left;
            border-radius: 10px;
            /* background-color: #07bcc6; */
       }
       .mysign{
            width: 96.5%;
            height: 2.5rem;
            border-radius: 2px;
            line-height: 2.5rem;
            text-align: center;
            margin-left: 1.35rem;
            color: rgb(171, 168, 168);
            float: left;
            background-color: #e1f2f575;
       }
       .mysign>img{
            width: 1rem;
            color: #ffc0cb;
       }
       #praise{
            margin-top: 150px;
       }
       #praise>span{
            display: inline-block;
            width: 6rem;
            height: 3rem;
            line-height: 3rem;
            text-align: center;
            border: #f57441b0 1px solid;
            background: #eeebea;
       }
       #praise>span>img{
            width: 2rem;
            margin-top: -10px;
       }
       #myphoto{
            margin: 1rem auto;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            box-shadow: rgb(147, 146, 146) 2px 2px 6px 1px;
            border: 5px rgb(226, 223, 223) solid;
       }
       #myphoto>img{
            width: 90px;
            height: 90px;
            border-radius: 50%;
       }
       #myname{
            width: 100%;
            height: 2rem;
            /* background: red; */
            font-size: 1.3rem;
            color: rgb(117, 114, 114);
            text-align: center;
            font-weight: bold;
       }
       #mysex{
            width: 100%;
            height: 2rem;
            line-height: 2rem;
            text-align: center;
            /* background: rgb(201, 241, 158); */
       }
       #mysex>img{
            margin-top: -2px;
            width: 1.3rem;
            margin-left: 10px;
       }
       .addfollow{
            display: block;
            width: 120px;
            height: 35px;
            float: right;
            margin-top: 160px;
            margin-left: 10px;
            text-align: center;
            line-height: 35px;
            border-radius: 5px;
            color: white;
            background-color: #3dc2d9af;
       }
       .addfollow>img{
            width: 1rem;
            height: 1rem;
       }
    </style>
</head>
<body>
    <!-- 登录 -->
    <div class="modal fade" id="myLogin">
        <div class="modal-dialog">
          <div class="modal-content">
       
            <!-- 模态框头部 -->
            <div class="modal-header">
              <h4 class="modal-title"> 用户登录 </h4>
              <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
       
            <!-- 模态框主体 -->
            <div class="modal-body">
                <form action="" method="post">
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                        <span class="input-group-text"> 输入电话 </span>
                        </div>
                        <input type="text" class="form-control" placeholder="Userphone" id="uPhone" name="">
                    </div>
                    <span  class="massge" id="lo_phone"></span>
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                        <span class="input-group-text"> 输入密码 </span>
                        </div>
                        <input type="password" class="form-control" placeholder="Userpassword" id="uPass" name="">
                    </div>
                    <span  class="massge" id="lo_pass"></span>
                </form>
            </div>
       
            <!-- 模态框底部 -->
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" id="login"> 登 录 </button>
            </div>
       
          </div>
        </div>
    </div>
    <script>
        $("#login").click(function(){
            var userPhone = $("#uPhone").val();
            var userPass = $("#uPass").val();
            var flag = true;
            var myreg=myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
            var message = "";
            if(userPhone == ''){
                message = "手机号码不能为空！";
                $('#lo_phone').text(message);
                return flag = false
            }else{
                $('#lo_phone').text('')
            }
            if(userPhone.length !=11){
                message = "请输入有效的手机号码！";
                $('#lo_phone').text(message);
                return flag = false
            }else{
                $('#lo_phone').text('')
            } 
            if(!myreg.test(userPhone)){
                message = "请输入有效的手机号码！";
                $('#lo_phone').text(message);
                return flag = false
            }else{
                $('#lo_phone').text('')
            }
            if(userPass == ''){
                message = "密码不能为空！";
                $('#lo_pass').text(message);
                return flag = false
            }else{
                $('#lo_pass').text('');
            }
            if(flag == true){
                $.ajax({
                    url: "http://cms.com:8081/index/index/userLogin",
                    type: "POST",
                    data: {
                        userPhone,
                        userPass
                    },
                    success: function (data) {
                        if(data == 3){
                            alert('账号已被禁用！');
                            window.location.reload()
                            return
                        }
                        if(data == 0){
                            alert('还没有注册！');
                            window.location.reload()
                            return
                        }
                        if(data == 2){
                            alert('账号或密码错误！');
                            window.location.reload()
                            return
                        }else{
                            var name = JSON.parse(data)
                            $("#userName").text(name.val.userName)
                            localStorage.setItem('void',name.key)
                            window.location.reload()
                            // console.log(name)
                        }
                    }
                }); 
            }
             
        })
    
        function init(){
            var res = localStorage.getItem('void');
            if(res != ''){
                $.ajax({
                    url: "http://cms.com:8081/index/index/getUserInfo",
                    type: "POST",
                    data: {
                        res
                    },
                    success: function (data) {
                        if(data != 0){
                            var name = JSON.parse(data)
                            $("#userName").text(name.userName)
                            $("#author").val(name.userName)
                            $("#del").remove()
                        } 
                    }
                });
            }
        }
        init()
    
        function mian(){
            var res = localStorage.getItem('void');
            if(res != ''){
                $.ajax({
                    url: "http://cms.com:8081/index/index/delUserInfo",
                    type: "POST",
                    data: {
                        res
                    },
                    success: function (data) {
                        if(data == 0){
                            alert('没有登录，快去登录！')
                            console.log(data)
                        }else{
                            var name = JSON.parse(data)
                            $("#userName").text(name.userName)
                            $("#useAavatar").attr('src','http://cms.com:8081/static/uploads/'+name.useAavatar)
                            localStorage.removeItem('void')
                            alert('退出成功！')
                            window.location.reload()
                        }
                        
                    }
                });
            }
        }
        getAavatar()
        function getAavatar(){
            var res = localStorage.getItem('void');
            if(res != null){
                $.ajax({
                    url:"http://cms.com:8081/index/index/getAavatar",
                    type:"POST",
                    data:{
                        redis:res
                    },
                    success:function(data){
                        var res = JSON.parse(data)
                        // console.log(res)
                        if(res.useAavatar != null){
                            $("#tou").attr('src','')
                            $("#changetou").attr('src','')
                            $("#tou").attr('src','http://cms.com:8081/../static/uploads/'+res.useAavatar)
                            $("#changetou").attr('src','http://cms.com:8081/../static/uploads/'+res.useAavatar)
                        }
                        
                    }
                });
            }
            
        }
    </script>
    <!-- 注册 -->
    <div class="modal fade" id="mySign">
        <div class="modal-dialog">
          <div class="modal-content">
       
            <!-- 模态框头部 -->
            <div class="modal-header">
              <h4 class="modal-title"> 用户注册 </h4>
              <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
       
            <!-- 模态框主体 -->
            <div class="modal-body">
                <form action="" method="post">
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                        <span class="input-group-text"> 输入电话 </span>
                        </div>
                        <input type="text" class="form-control" placeholder="Userphone" id="phone" name="">
                    </div>
                    <span  class="massge" id="ph_phone"></span>
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                        <span class="input-group-text"> 输入昵称 </span>
                        </div>
                        <input type="text" class="form-control" placeholder="Username" id="name" name="">
                    </div>
                    <span  class="massge" id="na_name"></span>
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                        <span class="input-group-text"> 输入密码 </span>
                        </div>
                        <input type="password" class="form-control" placeholder="Userpassword" id="pass" name="">
                    </div>
                    <span  class="massge" id="pa_pass"></span>
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                        <span class="input-group-text"> 确认密码 </span>
                        </div>
                        <input type="password" class="form-control" placeholder="Userpassword" id="repass" name="">
                    </div>
                    <span  class="massge" id="re_pass"></span>
                </form>
            </div>
       
            <!-- 模态框底部 -->
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" id="sign"> 注 册 </button>
            </div>
       
          </div>
        </div>
    </div>
    <script>
        $("#sign").click(function(){
            var userPhone = $("#phone").val();
            var userName = $("#name").val();
            var userPass = $("#pass").val();
            var userRePass = $("#repass").val();
            var flag = true;
            var myreg=myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
            var message = "";
            if(userPhone == ''){
                message = "手机号码不能为空！";
                $('#ph_phone').text(message);
                return flag = false
            }else{
                $('#ph_phone').text('')
            }
            if(userPhone.length !=11){
                message = "请输入有效的手机号码！";
                $('#ph_phone').text(message);
                return flag = false
            }else{
                $('#ph_phone').text('')
            } 
            if(!myreg.test(userPhone)){
                message = "请输入有效的手机号码！";
                $('#ph_phone').text(message);
                return flag = false
            }else{
                $('#ph_phone').text('')
            }
            if(userName == ''){
                message = "昵称不能为空！";
                $('#na_name').text(message);
                return flag = false
            }else{
                $('#na_name').text('')
            } 
            if(userName.length <2){
                message = "昵称不能小于两个字！";
                $('#na_name').text(message);
                return flag = false
            }else{
                $('#na_name').text('')
            } 
            if(userName.length >5){
                message = "昵称不能多于5个字！";
                $('#na_name').text(message);
                return flag = false
            }else{
                $('#na_name').text('')
            } 
            if(userPass == ''){
                message = "密码不能为空！";
                $('#pa_pass').text(message);
                return flag = false
            }else{
                $('#pa_pass').text('');
            } 
            if(userPass.length <6){
                message = "密码不能少于6位数！";
                $('#pa_pass').text(message);
                return flag = false
            }else{
                $('#pa_pass').text('');
            } 
            if(userPass == ''){
                message = "请再次确认密码！";
                $('#re_pass').text(message);
                return flag = false
            }else{
                $('#re_pass').text('');
            } 
            if(userPass != userRePass){
                message = "两次输入的密码不相同！";
                $('#re_pass').text(message);
                return flag = false
            }else{
                $('#re_pass').text('');
            }
            if(flag == true){
               $.ajax({
                    url: "http://cms.com:8081/index/index/userSign",
                    type: "POST",
                    data: {
                        userPhone,
                        userName,
                        userPass
                    },
                    success: function (data) {
                        if(data==0){
                            alert('已有账号！')
                            window.location.reload()
                            return
                        }
                        if(data==1){
                            alert('注册成功！')
                            window.location.reload()
                        }else{
                            alert('注册失败！')
                            window.location.reload()
                        }
                    }
                }); 
            }
            
        })
    </script>
    <div class="box">
        <header>
            <nav class="navbar navbar-expand-sm" style="background-color:rgba(114, 190, 234, 0.289);font-size: 16px;">
                <div class="imgbox">
                    <img class="img" src="./imge/logo1.png" alt="">
                    <ul class="nav nav-pills" role="tablist" id="tablist">
                        <li class="nav-item">
                            <a class="nav-link actives" href="index.html">网站首页</a>
                        </li>
                        <li class="nav-item" style="margin-left: 5px;color: white;">
                            <a class="nav-link actives" onclick="back()">返回</a>
                        </li>
                    </ul>
                </div>
                <div class="login" style="width: 32%; font-size: 16px;float: right;height: 66px;">
                    <img src="./imge/0.png" alt="" class="tou" id="tou">
                    <div style="float: left; width: 10rem;text-align: center; line-height: 66px;">
                        <div class="dropdown">
                            <span type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" id="userName">
                              
                            </span>
                            <div class="dropdown-menu" style="background-color:rgb(215, 236, 247); padding-bottom: 0;" id="bacLogin">
                              <!-- <a href="javascript:;" class="dropdown-item" >修改密码</a>
                              <a href="javascript:;" class="dropdown-item" >上传头像</a> -->
                              <a href="userinfo.html" class="dropdown-item" >个人信息</a>
                              <span id="deLogin" onclick="mian()" class="dropdown-item" style="border-top: 1px rgb(123, 122, 122) solid;">退出登录</span>
                            </div>
                        </div>
                    </div>
                    <div style="width: 44%;float:right;line-height: 66px;">
                        <!-- <img src="./imge/write.png" alt="" class="key"><a href="dome.html">写文章</a> -->
                        <span id="del"><img src="./imge/钥匙2_key-two.png" alt="" class="key"><a href="javascript:;" data-toggle="modal" data-target="#myLogin"> 登录</a></span> 
                        <img src="./imge/创建_newlybuild.png" alt="" class="key key2"><a href="javascript:;" data-toggle="modal" data-target="#mySign"> 注册</a> 
                    </div>
                </div>
              </nav>
        </header>
        
        <div class="cotent">
            <article style="height:100%;width: 100%;background-color: rgba(218, 229, 253, 0.163);padding: 15px 1rem;overflow: auto;display:flex;flex-direction: column;justify-content: flex-start;align-items: center;padding-top: 0;">
                <div id="imgheader">
                    <ul class="imgheader_ul" >
                        <li id="praise">
                            <span><img src="./imge/two.png" alt=""> ( 90 )</span>
                        </li>
                    </ul>
                    <ul class="imgheader_ul">
                        <li id="myphoto"><img src="./imge/3.jpg" alt="" id="myphoto_img"></li>
                        <li id="myname"><span id="author_name">无</span></li>
                        <li id="mysex">
                            <img src="./imge/male.png" alt=""> <span  id="author_sex"> 无</span>
                            <img src="./imge/local.png" alt=""> <span id="author_local"> 无</span>
                            <img src="./imge/cake.png" alt=""> <span  id="author_read"> 无</span>
                        </li>
                    </ul>
                    <ul class="imgheader_ul">
                        <li id="addspan">
                            <!-- <span class="addfollow"><img src="./imge/envelope-one.png" alt=""> 发送私信</span> -->
                            <!-- <span class="addfollow" onclick="follow()"><img src="./imge/personal-collection.png" alt=""> 添加关注</span> -->
                        </li>
                    </ul>
                    <ul class="mysign">
                        <img src="./imge/sign.png" alt=""><span style="color: black;">个性签名：</span><span id="author_sign">无</span>
                    </ul>
                </div>
                
            </article>
        </div>
        <div class="footer">
            <p style="font-size: 0.9rem;"> 网站首页 | 关于网站 | 网站地图 </p>
            <p>文字站感谢每一位喜欢本站的人，欢迎将本站分享给你的朋友！最温暖的文字记录站 ─ 文字站！</p>
            <p>本站部分内容来源于互联网，若无意侵犯您的权利，请联系我们及时删除</p>
            <p style="font-size: 0.9rem;">渝ICP备99999999号  Copyright © 2015  文字站   www.xiaowumeiwen.com  版权所有</p>
        </div>
    </div>
    <input type="hidden" name="" id="myID">
    <script>
    var redis = localStorage.getItem('void');
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg); //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
    }
    function getAuthor(){
        var id = getUrlParam('uid')
        // console.log(id)
        $.ajax({
            url:"http://cms.com:8081/index/index/getAuthor",
            type:'POST',
            data: {id},
            success:function(data){
                var res = JSON.parse(data)
                console.log(res)
                if(res != null){
                    $("#addspan").empty()
                    $("#myphoto_img").attr('src','')
                    $("#myphoto_img").attr('src','http://cms.com:8081/../static/uploads/'+res[0].getUser[0].useAavatar)
                    $("#author_name").text(res[0].getUser[0].userName)
                    $("#author_sex").text(res[0].sex)
                    $("#author_local").text(res[0].place)
                    $("#author_read").text(res[0].birth)
                    $("#author_sign").text(res[0].sign)
                    var $li = '<span class="addfollow"><img src="./imge/envelope-one.png" alt=""> 发送私信</span>'+
                            '<span class="addfollow" onclick="follow('+res[0].uID+')"><img src="./imge/personal-collection.png" alt=""> 添加关注</span>'
                    $("#addspan").append($li)
                }
            }
        })
    }getAuthor()
    
    function follow(e){
        console.log(e)
        if(redis != null){
            $.ajax({
                url:"http://cms.com:8081/index/index/follow",
                type:"POST",
                data:{
                    uID:e,
                    redis:redis
                },
                success:function(data){
                    if(data == 0){
                        alert('不能关注自己哟！')
                        getAuthor()
                    }
                    if(data == 2){
                        alert('已经关注过了哟！')
                        getAuthor()
                    }
                    if(data == 1){
                        alert('关注成功！')
                        getAuthor()
                    }
                }
            });
        }else{
            alert('你还没有登录')
        }
        
    }
    function back(){
        history.back(-1)
    }
    </script>
    
    

    </body>
</html>
    